<?php
/**
 * @Author: xuzhiyi
 * @Date:   2016-02-16 20:57:19
 * @Last Modified by:   xuzhiyi
 * @Last Modified time: 2016-02-19 21:42:20
 * ------------------------------------------------ *
 * 会员级别                                         *
 * ------------------------------------------------ */

namespace Admin\Controller;
class UserRanksController extends CommonController {
	public function index(){
		if(IS_AJAX){
			switch(I('ajax')){
				
				case "addUserRanks":
					$a = D('user_ranks')->addUserRanks();
					if($a){
						$this->success('级别添加成功！','',true);	
					}
					$this->error('级别添加失败！','',true);
					break;
				case "delUserRanks":
					$status = D('user_ranks')->delUserRanks();
					$this->ajaxReturn($status);
					break;
				case "editUserRanks":
					$a = D('user_ranks')->editUserRanks();
					if($a){
						$this->success('权限修改成功！','',true);	
					}
					$this->error('权限修改失败！','',true);
					break;
				default:
					$a=M('user_ranks');
			 		$result = $a->order('rebate desc')->select();
			 		$output['data'] = $result;
			 		$this->ajaxReturn($output);

			}
		}

		$this->display();
	}

}